
#include "Rook.h"

Rook::Rook(bool white): Piece(white) {
}

std::string Rook::GetType() const{
   return "rook";
}

std::set<BoardPosition> Rook::GetAllMoves(Board * b, BoardPosition curPos) {
   std::set<BoardPosition> ReturnSet;

   for (int i=-7; i <8; i++) {

      //Rook moves
      BoardPosition pos(curPos.GetRow()+i, curPos.GetCol());
      if (pos.IsOnBoard())
         ReturnSet.insert(pos);
      pos = BoardPosition(curPos.GetRow(), curPos.GetCol()+i);
      if (pos.IsOnBoard())
         ReturnSet.insert(pos);
   }

   return ReturnSet;
}

std::set<BoardPosition> Rook::GetLegalMoves(Board * b, BoardPosition curPos){
   std::set<BoardPosition> ReturnSet;

   for (int i=-7; i <8; i++) {

      //Rook moves
      BoardPosition pos(curPos.GetRow()+i, curPos.GetCol());
      if (pos.IsOnBoard())
         ReturnSet.insert(pos);
      pos = BoardPosition(curPos.GetRow(), curPos.GetCol()+i);
      if (pos.IsOnBoard())
         ReturnSet.insert(pos);
   }

   return ReturnSet;
}
